home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / wardial.arc / WARDIAL.PAS < prev   
Pascal/Delphi Source File  |  1986-04-30  |  37KB  |  1,418 lines

  1.  
  2. { ****************************************************************************
  3.   *                                                                          *
  4.   *                        Wardial 1.2 By Jim Everingham                     *
  5.   *                        ------------------------------                    *
  6.   *     This Program is released to public domain by Jim Everingham. It      *
  7.   *     May be distributed and modified at will.  This program utilizes      *
  8.   *     the commcall routines by Allen Bishop.  I have not cleaned up        *
  9.   *     this source code, so it may seem a bit messy.  It can be shortened   *
  10.   *     substantially if given a little time. Any questions can be sent      *
  11.   *     to:                                                                  *
  12.   *                            Jim Everingham                                *
  13.   *                            215 West Fairmount Ave                        *
  14.   *                            Apt 306 Fairmount Hills                       *
  15.   *                            State College, Pa 16801                       *
  16.   *                                                                          *
  17.   ****************************************************************************  }
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27. {$C-}
  28. Procedure wardial;forward;
  29. Procedure menu;forward;
  30. Procedure Set_modem_parameters;forward;
  31. Procedure beep; forward;
  32.  
  33. const
  34.    Windows    = 5;
  35.    Wtab       : array[1..Windows,1..5] of Integer
  36.                 = (( 5,  2,  75, 10,  1),
  37.                    ( 5,  14,  33, 23,  1),
  38.                    ( 46, 14,  75, 23,  1),
  39.                    ( 5,  23,  75, 24, 1),
  40.                    ( 1,  1,   80, 21, 1)
  41.                   );
  42.    recv_buf_size = 4096;   {Recieve buffer size, can be changed}
  43.  
  44. type buffer_pointer   = integer;
  45.      smallstring      = string[2];
  46.      bigstring        = string[255];
  47.      storage          = byte;
  48.      check_bit        = (none,even);
  49.      sd = string[40];
  50.      st = string[8];
  51.      string255=string[255];
  52.  
  53. var leave                 : boolean;  {end of routine marker}
  54.     buf_start, buf_end    : buffer_pointer;
  55.     stop_time             : sd;
  56.     recv_buffer           : array [1..recv_buf_size] of storage;
  57.     speed                 : integer;
  58.     Service_number, Num, Checksum_number,code: sd;
  59.     dbits                 : integer;
  60.     stop_bits             : integer;
  61.     parity                : check_bit;
  62.     code_found            : array[1..20] of sd;
  63.     zz,code_length        : integer;
  64.     ch                    : char;
  65.     ii                    : integer;
  66.     Xon,Xoff              : char;
  67.     screen1               : Array[1..4000] of byte absolute $B800:$0000;
  68.     screen2               : Array[1..4000] of byte;
  69.     Xcoord,ycoord,x2,y2   : Integer;
  70.     Dial_Speed,Dial_type,Speaker,Duplex,Command_echo,Response_time:sd;
  71.     maincolor             : integer;
  72.     Print_stat            : boolean;
  73.     Printer               : boolean;
  74.     Dial_command,Pause_command,Start_num:string[20];
  75.  
  76. Procedure init_screen;
  77. begin
  78. lowvideo;
  79. window(1,1,80,25);
  80. clrscr;
  81. end;
  82.  
  83.  
  84. function time2 : st;
  85. type
  86.   registors = record
  87.               ax,bx,cx,dx,bp,si,ds,es,flags: integer;
  88.               end;
  89. var
  90.   regisrec               : registors;
  91.   hour , minute , second : string[2];
  92.   cx , dx                : integer;
  93. begin
  94.   with regisrec do
  95.   begin
  96.     ax := $2C shl 8;
  97.   end;
  98.   msdos(regisrec);
  99.   with regisrec do
  100.   begin
  101.     str(cx shr 8 , hour);
  102.     str(cx mod 256 , minute);
  103.     str(dx shr 8 , second);
  104.   end;
  105.   if length(hour  ) = 1 then insert('0',hour  ,1);
  106.   if length(minute) = 1 then insert('0',minute,1);
  107.   if length(second) = 1 then insert('0',second,1);
  108.   time2:= hour + ':' + minute + ':' + second
  109. end;
  110.  
  111.  
  112.  
  113. function time : st;
  114. type
  115.   registors = record
  116.               ax,bx,cx,dx,bp,si,ds,es,flags: integer;
  117.               end;
  118. var
  119.   regisrec               : registors;
  120.   hour , minute , second : string[2];
  121.   cx , dx                : integer;
  122. begin
  123.   with regisrec do
  124.   begin
  125.     ax := $2C shl 8;
  126.   end;
  127.   msdos(regisrec);
  128.   with regisrec do
  129.   begin
  130.     str(cx shr 8 , hour);
  131.     str(cx mod 256 , minute);
  132.     str(dx shr 8 , second);
  133.   end;
  134.   if length(hour  ) = 1 then insert(' ',hour  ,1);
  135.   if length(minute) = 1 then insert('0',minute,1);
  136.   if length(second) = 1 then insert('0',second,1);
  137.   time := minute + second
  138. end;
  139.  
  140.  
  141.  
  142. procedure check_range(var range : integer);
  143. begin
  144.  if range > recv_buf_size then range := 1;
  145. end;
  146.  
  147. function commpressed : boolean;
  148. begin
  149.  commpressed := (buf_start <> buf_end);
  150. end;
  151.  
  152. function cinkey : smallstring;
  153. var result : smallstring;
  154.     temp   : integer;
  155. begin
  156.  if not commpressed then result := ''
  157.  else
  158.  begin
  159.   inline ($FA);  {very important}
  160.   temp := recv_buffer[buf_start];
  161.   buf_start := buf_start +1;
  162.   check_range(buf_start);
  163.   inline ($FB);  {very important}
  164.   result := chr(temp);
  165.  end;
  166.  cinkey := result;
  167. end;
  168.  
  169.  
  170. function carrier : boolean;
  171. begin
  172.  carrier := odd(port[$3FE] shr 7);
  173. end;
  174.  
  175. procedure set_up_recv_buffer;
  176. begin
  177.  buf_start := 1;
  178.  buf_end   := 1;
  179. end;
  180.  
  181. procedure set_baud(rate : integer);
  182. var a : byte;
  183.     divided : real;
  184. begin
  185.  if rate<=9600 then
  186.  begin
  187.   speed := rate;
  188.   divided := 115200.0/rate;
  189.   rate := trunc(divided);
  190.   a := port[$3fb];
  191.   if a < 128 then a := a+128;
  192.   port[$3fb] := a;
  193.   port[$3f8] := lo(rate);
  194.   port[$3f9] := hi(rate);
  195.   port[$3fb] := a-128;
  196.  end;
  197. end;
  198.  
  199. procedure update_uart;
  200. var a : byte;
  201. begin
  202.  a := dbits-5;
  203.  if stop_bits = 2 then a := a + 4;
  204.  if parity = even then a := a + 24;
  205.  port[$3fb] := a;
  206. end;
  207.  
  208.  
  209. procedure init_port;
  210. var a,b : integer;
  211.     buf_len : integer;
  212. begin
  213.  update_uart;
  214.  port[$3f9] := 1;             {interupt enable}
  215.  a := port[$3fc];
  216.  if odd(a) then a := 1 else a := 0;   {keep terminal ready}
  217.  a := a+10;
  218.  port[$3fc] := a;                     {turn on req to send and out2}
  219.  a := port[$3fa];
  220.  port[$21]  := $c;
  221.  set_baud(speed);
  222.  buf_len := recv_buf_size;
  223.  
  224.  {this is the background routine}
  225.  
  226.  inline (
  227.   $1E/
  228.   $0E/
  229.   $1F/
  230.   $BA/*+23/
  231.   $B8/$0C/$25/
  232.   $CD/$21/
  233.   $8B/$BE/BUF_LEN/
  234.   $89/$3E/*+87/
  235.   $1F/
  236.   $2E/$8C/$1E/*+83/
  237.   $EB/$51/
  238.   $FB/
  239.   $1E/
  240.   $50/
  241.   $53/
  242.   $52/
  243.   $56/
  244.   $2E/$8E/$1E/*+70/
  245.   $BA/$F8/$03/
  246.   $EC/
  247.   $BE/RECV_BUFFER/
  248.   $8B/$1E/BUF_END/
  249.   $88/$40/$FF/
  250.   $43/
  251.   $E8/$22/$00/
  252.   $89/$1E/BUF_END/
  253.   $3B/$1E/BUF_START/
  254.   $75/$0C/
  255.   $8B/$1E/BUF_START/
  256.   $43/
  257.   $E8/$10/$00/
  258.   $89/$1E/BUF_START/
  259.   $BA/$20/$00/
  260.   $B0/$20/
  261.   $EE/
  262.   $5E/
  263.   $5A/
  264.   $5B/
  265.   $58/
  266.   $1F/
  267.   $CF/
  268.   $2E/$8B/$16/*+11/
  269.   $42/
  270.   $39/$DA/
  271.   $75/$03/
  272.   $BB/$01/$00/
  273.   $C3/
  274.   $00/$00/
  275.   $00/$01/
  276.   $90
  277.  );
  278. end;
  279.  
  280. procedure term_ready(state : boolean);
  281. var a : byte;
  282. begin
  283.  a := port[$3fc];
  284.  if odd(a) then a := a - 1;
  285.  a := a + ord(state);
  286.  port[$3fc] := a;
  287. end;
  288.  
  289. procedure remove_port;
  290. var a : byte;
  291. begin
  292.  port[$3f9] := 0;
  293.  a := port[$3fc];
  294.  if odd(a) then a := 1 else a := 0;
  295.  port[$3fc] := a;
  296.  port[$21]  := $BC;
  297. end;
  298.  
  299. procedure write_byte(to_send : bigstring);
  300. var a,b,c : byte;
  301. begin
  302.  for b := 1 to length(to_send) do
  303.  begin
  304.   c := ord(to_send[b]);
  305.   repeat a := port[$3fd];
  306.   until odd(a shr 5);
  307.   port[$3f8] := c;
  308.  end;
  309. end;
  310.  
  311.    procedure Frame(UpperLeftX, UpperLeftY, LowerRightX, LowerRightY: Integer);
  312.    var
  313.       i: Integer;
  314.    begin
  315.       GotoXY(UpperLeftX, UpperLeftY);  Write(chr(201));
  316.       for i:=UpperLeftX+1 to LowerRightX-1 do Write(chr(205));
  317.       Write(chr(187));
  318.       for i:=UpperLeftY+1 to LowerRightY-1 do
  319.       begin
  320.          GotoXY(UpperLeftX , i);  Write(chr(186));
  321.          GotoXY(LowerRightX, i);  Write(chr(186));
  322.       end;
  323.       GotoXY(UpperLeftX, LowerRightY);
  324.       Write(chr(200));
  325.       for i:=UpperLeftX+1 to LowerRightX-1 do Write(chr(205));
  326.       Write(chr(188));
  327.    end  { Frame };
  328.  
  329. {$I Send_asc.pas}
  330. {$I Rcv_asc.pas}
  331.  
  332. procedure break;
  333. var a,b : byte;
  334. begin
  335.  a := port[$3fb];
  336.  b := a;
  337.  if b > 127 then b := b - 128;
  338.  if b <= 63 then b := b + 64;
  339.  port[$3fb] := b;
  340.  delay(400);
  341.  port[$3fb] := a;
  342. end;
  343.  
  344. procedure setup;
  345. var a : byte;
  346. begin
  347.  dbits        := 8;
  348.  parity       := none;
  349.  stop_bits    := 1;
  350.  speed        := 1200;
  351.  init_port;
  352.  term_ready(true);
  353. end;
  354.  
  355. Procedure Help_wardial;
  356. var a:char;
  357. begin
  358.      write_byte(chr(13));
  359.      xcoord:=wherex;
  360.      ycoord:=wherey;
  361.      move(screen1,screen2,4000);
  362.      normvideo;
  363.      lowvideo;
  364.      window(1,1,80,25);
  365.      normvideo;
  366.      textcolor(12);
  367.      frame(24,9,56,21);
  368.      lowvideo;
  369.      window(25,10,55,20);
  370.      textcolor(15);
  371.      clrscr;
  372.      gotoxy(10,1);
  373.      writeln('Help Menu');
  374.      gotoxy(1,3);
  375.      textcolor(7);
  376.      writeln('  <Alt-P>  Toggle Printer ');
  377.      writeln('  <Alt-M>  Set Modem Params');
  378.      writeln('  <Alt-X>  Exit to Menu');
  379.      gotoxy(1,10);
  380.      textcolor(white+blink);
  381.      writeln('        Hit any Key');
  382.      repeat until keypressed;
  383.      normvideo;
  384.      lowvideo;
  385.      window(1,1,80,25);
  386.      normvideo;
  387.      textcolor(12);
  388.      move(screen2,screen1,4000);
  389.      window(5,14,33,23);
  390.      gotoxy(xcoord,ycoord);
  391. end;
  392.  
  393.  
  394.  
  395. Procedure beep;
  396. begin
  397.      sound(2000);
  398.      delay(100);
  399.      nosound;
  400. end;
  401.  
  402.  
  403.    procedure SelectWindow(Win: Integer);
  404.    begin
  405.       Window(Wtab[Win,1], Wtab[Win,2], Wtab[Win,3], Wtab[Win,4])
  406.    end  { SelectWindow };
  407.  
  408. Procedure Toggle_printer;
  409. var b,temp:sd;
  410. begin
  411. beep;
  412. if Print_stat then
  413.      begin
  414.            Print_stat:=false;
  415.            write(lst,chr(12));
  416.      end
  417. else
  418.     begin
  419.          b:=num;
  420.          write(lst,'WARDIAL 1.2':25,'SEARCHING:':30);
  421.          if copy(b,1,1)='1' then temp:=copy(b,1,1)+'-'
  422.          else temp:=copy(b,5,3)+'-';
  423.          if copy(b,2,3)='800' then temp:=temp+'800-'+copy(b,5,3)+'-'+copy(b,8,4)
  424.          else temp:=num;
  425.          write(lst,temp);
  426.          writeln(lst);
  427.          Print_stat:=true;
  428.          writeln(lst);
  429.          writeln(lst,'Code Number':12,'Code':12);
  430.          writeln(lst);
  431.     end;
  432. end;
  433.  
  434. Procedure Toggle3_printer;
  435. var b,temp:sd;
  436. begin
  437. beep;
  438. if Print_stat then
  439.      begin
  440.            Print_stat:=false;
  441.            write(lst,chr(12));
  442.      end
  443. else
  444.     begin
  445.          writeln(lst,'WARDIAL 1.2':25,'SEARCHING FOR CARRIERS':30);
  446.          writeln(lst);
  447.          Print_stat:=true;
  448.          writeln(lst);
  449.          writeln(lst,'Carriers at':10);
  450.          writeln(lst);
  451.     end;
  452. end;
  453.  
  454. Procedure All_codes;
  455. var k:integer;
  456. begin
  457. if zz>0 then
  458.       begin
  459.            Normvideo;
  460.            lowvideo;
  461.            window(1,1,80,25);
  462.            normvideo;
  463.            textcolor(12);
  464.            Frame(9,3,21,20);
  465.            lowvideo;
  466.            textcolor(7);
  467.            window(10,4,20,19);
  468.            ClrScr;
  469.            gotoxy(1,15);
  470.            textcolor(7);
  471.            for k:=1 to zz do
  472.                begin
  473.                     writeln(code_found[k]:8);
  474.                     if k=13 then
  475.                              begin
  476.                                   textcolor(white+blink);
  477.                                   write(' Hit a Key');
  478.                                   repeat until keypressed;
  479.                                   textcolor(7);
  480.                              end;
  481.                     insline;
  482.                end;
  483.          textcolor(white+blink);
  484.          write(' Hit a Key');
  485.          repeat until keypressed;
  486.     end;
  487. end;
  488.  
  489.  
  490. Procedure test_carrier(var test:boolean; code:sd; timing_constant:integer);
  491. var i,j,k,result: integer;
  492.               cr: char;
  493. begin
  494.      val(time,i,result);
  495.      j:=i+timing_constant;
  496.      while (j>i) do
  497.            begin
  498.            val(time,i,result);
  499.            if carrier then
  500.               begin
  501.               zz:=zz+1;
  502.               code_found[zz]:=code;
  503.               textcolor(white+blink);
  504.               write('Code Found!');
  505.               sound(1000);
  506.               delay(500);
  507.               nosound;
  508.               if Print_stat then  writeln(lst,zz:6,code:20);
  509.               write_byte('+++');
  510.               delay (3000);
  511.               Write_byte('ATH0');
  512.               j:=i-26;
  513.               end;
  514.            if keypressed then
  515.               begin
  516.                    read(kbd,cr);
  517.                    if cr=chr(25) then toggle_printer else
  518.                    if cr=chr(35) then Help_wardial else
  519.                    if cr=chr(50) then begin
  520.                                            set_modem_parameters;
  521.                                            gotoxy(xcoord,ycoord);
  522.                                            end
  523.                                       else
  524.                    if cr=chr(45) then
  525.                       begin
  526.                          j:=i-26;
  527.                          test:=true;
  528.                          All_codes;
  529.                          end;
  530.                       end;
  531.            end;
  532. write_byte('-');
  533. write_byte(chr(13));
  534. for i:=1 to maxint do ;;
  535. end;
  536.  
  537. Procedure Send_code(service_number,code,checksum_number:sd);
  538. var i,j: integer;
  539. outword:sd;
  540. begin
  541. outword:=service_number+code+checksum_number+chr(13);
  542. Lowvideo;
  543. selectwindow(2);
  544. gotoxy(1,1);
  545. insline;
  546. textcolor(12);
  547. write('   TRYING: ',code);
  548. normvideo;
  549. write_byte(outword);
  550. end;
  551.  
  552. Procedure write_codes;
  553. var i:integer;
  554. begin
  555. lowvideo;
  556. selectwindow(3);
  557. gotoxy(1,1);
  558. CLrScr;
  559. textcolor(12);
  560. if zz=0 then writeln('   NO CODES')
  561. else for i:=1 to zz do writeln('  CODE AT: ',code_found[i]);
  562. normvideo;
  563. end;
  564.  
  565.  
  566. Procedure Get_code(var code:sd);
  567. var i,j: integer;
  568. a,b: sd;
  569. begin
  570.      repeat
  571.            i:=random(999)
  572.      until i > 100;
  573.      str(i,a);
  574.      if code_length > 5 then
  575.               begin
  576.                    i:=random(9);
  577.                    str(i,b);
  578.                    a:=a+b;
  579.               end;
  580.      if code_length > 6 then
  581.               begin
  582.                    i:=random(9);
  583.                    str(i,b);
  584.                    a:=a+b;
  585.               end;
  586.  
  587.      if code_length > 7 then
  588.               begin
  589.                    i:=random(9);
  590.                    str(i,b);
  591.                    a:=a+b;
  592.               end;
  593.      i:=random(9);
  594.      str(i,b);
  595.      code:=Start_num+a+b;
  596. end;
  597.  
  598. Procedure help;
  599. begin
  600. xcoord:=whereX;
  601. ycoord:=wherey;
  602. move (screen1,screen2,4000);
  603. textcolor(lightblue);
  604. frame(45,1,75,16);
  605. lowvideo;
  606. window(46,2,74,15);
  607. textcolor(15);
  608. clrscr;
  609. gotoxy(1,1);
  610. writeln('        Help Menu');
  611. textcolor(7);writeln;
  612. writeln(' <Alt-Y>  Displays menu');
  613. writeln(' <Alt-P>  To set Parameters');
  614. writeln(' <Alt-E>  To Toggle Echo');
  615. writeln(' <Alt-Q>  Returns to menu');
  616. Writeln(' <Alt-O>  Hangs up Modem');
  617. writeln(' <Alt-A>  Modem Parameters');
  618. writeln(' <Alt-S>  Send Ascii File');
  619. writeln(' <Alt-R>  Recieve file Ascii');
  620. writeln(' <Alt-W>  Dial Number ');
  621. gotoxy(1,14);
  622. textcolor(white+blink);
  623. write('      Press Any Key');
  624. repeat until keypressed;
  625. normvideo;
  626. lowvideo;
  627. selectwindow(5);
  628. textcolor(lightcyan);
  629. move(screen2,screen1,4000);
  630. gotoxy(xcoord,ycoord);
  631. end;
  632.  
  633.  
  634. Procedure Set_parameters;
  635. var temp: sd;
  636. result:integer;
  637. begin
  638. xcoord:=whereX;
  639. ycoord:=whereY;
  640. move (screen1,screen2, 4000);
  641. textcolor(lightblue);
  642. frame(10,5,65,15);
  643. lowvideo;
  644. window(11,6,64,14);
  645. writeln;
  646. normvideo;
  647. clrscr;
  648. gotoxy(1,2);
  649. if parity=even then temp:='Even' else temp:='None';
  650. textcolor(7);
  651. writeln('   Current Parameters: ',Speed:4,'-',Stop_bits:2,'-',temp:5,'-',Dbits:2 );writeln;
  652. write('   Enter Baud      : ');readln(temp);
  653. if length(temp)>1 then val(temp,speed,result);
  654. write('   Enter Stop bits : ');readln(temp);
  655. if length(temp)>0 then val(temp,stop_bits,result);
  656. write('   Parity <E>ven <N>one : ');readln(temp);
  657. if length(temp) >0 then if (copy(temp,1,1)='E') or (copy(temp,1,1)='e') then parity:=even
  658. else parity:=none;
  659. write('   Enter Data bits : ');readln(temp);
  660. if length(temp)>0 then val(temp,dbits,result);
  661. init_port;
  662. textcolor(lightcyan);
  663. lowvideo;
  664. selectwindow(5);
  665. move (screen2,screen1, 4000);
  666. gotoxy(Xcoord,Ycoord);
  667. end;
  668.  
  669. Procedure Set_Modem_Parameters;
  670. var temp:sd;
  671. begin
  672. write_byte(chr(13));
  673. xcoord:=wherex;
  674. ycoord:=wherey;
  675. move (screen1,screen2,4000);
  676. NormVideo;
  677. lowvideo;
  678. window(1,1,80,25);
  679. Normvideo;
  680. Textcolor(12);
  681. frame(38,1,73,13);
  682. LowVideo;
  683. window(39,2,72,12);
  684. Clrscr;
  685. gotoxy(1,1);
  686. textcolor(white);
  687. writeln('         Modem Parameters');
  688. gotoxy(1,4);
  689. textcolor(7);
  690. Writeln('      Dial Speed     ',Dial_speed:3,': ');
  691. Writeln('      <P>ulse <T>one ',Dial_type:3,': ');
  692. if Speaker='M0' then temp:='OFF' else temp:='ON';
  693. writeln('      Speaker        ',Temp:3,': ');
  694. if Duplex='F0' then temp:='HALF' else Temp:='FULL';
  695. writeln('      Duplex is     ',temp:4,': ');
  696. if Command_echo='E0' then temp:='OFF' else temp:='ON';
  697. writeln('      Command Echo   ',temp:3,': ');
  698. writeln('      Response Time  ',Response_time:3,': ');
  699. gotoxy(1,10);
  700. textcolor(white+blink);
  701. write('           Enter Values');
  702. textcolor(7);
  703. gotoxy(27,4);readln(temp);
  704. if length(temp) > 1 then Dial_speed:=temp;
  705. gotoxy(27,4);readln(temp);
  706. if length(temp) > 0 then dial_type:=upcase(copy(temp,1,1));
  707. gotoxy(27,5);readln(temp);
  708. if length(temp) > 0 then if (temp='Off') or (temp='off') or (temp='OFF') then Speaker:='M0';
  709. gotoxy(27,6);readln(temp);
  710. if length(temp) > 0 then if Upcase(copy(temp,1,1))='H' then Duplex:='F0';
  711. gotoxy(27,7);readln(temp);
  712. if length(temp) > 0 then if (temp='Off') or (temp='off') or (temp='OFF') then Command_echo:='E0';
  713. gotoxy(27,8);readln(temp);
  714. if length(temp) > 0 then response_time:=temp;
  715. gotoxy(1,10);textcolor(lightcyan+blink);
  716. write('      Please Wait: Working');
  717. if carrier then write_byte('+++');
  718. delay(2000);
  719. temp:='ATS11='+dial_speed+chr(13);write_byte(temp);delay(1000);
  720. temp:='AT'+Speaker+chr(13);write_byte(temp);delay(1000);
  721. temp:='AT'+Duplex+chr(13);write_byte(temp);delay(1000);
  722. temp:='AT'+Command_echo+chr(13);write_byte(temp);delay(1000);
  723. temp:='ATS9='+response_time+chr(13);write_byte(temp);delay(1000);
  724. if carrier then write_byte('ATA');write_byte(chr(13));beep;beep;
  725. normvideo;
  726. lowvideo;
  727. window(1,1,80,25);
  728. move(screen2,screen1,4000);
  729. textcolor(maincolor);
  730. end;
  731.  
  732.  
  733.  
  734.  
  735. Procedure Hang_up;
  736. var i,j:integer;
  737. begin
  738. Sound(500);
  739. delay(100);
  740. nosound;
  741. write_byte('+++');
  742. delay (3000);
  743. Write_byte('ATH0');
  744. Write_byte(chr(13));
  745. sound(500);
  746. delay(100);
  747. nosound;
  748. Delay(200);
  749. sound(500);
  750. delay(100);
  751. nosound;
  752. end;
  753.  
  754.  
  755. Procedure Sequential_dial;
  756. var prefix,temp,start_pos,end_pos,t2:sd;
  757.     a,b,c,i,j,k,timing_Constant:integer;
  758.     dial_stop:boolean;
  759.     ab:char;
  760. begin
  761.       NormVideo;
  762.       Lowvideo;
  763.       window(1,1,80,25);
  764.       normvideo;
  765.       clrscr;
  766.       textcolor(12);
  767.       frame(5,2,75,6);
  768.       textcolor(11);
  769.       frame(5,8,75,21);
  770.       gotoxy(7,4);
  771.       textcolor(15);
  772.       Write('                  Wardial 1.2       Sequential dialer');
  773.       lowvideo;
  774.       window(6,9,73,19);
  775.       gotoxy(1,3);
  776.       textcolor(12);
  777.       Writeln('  Set Paramters');
  778.       textcolor(cyan);
  779.       writeln;
  780.       write('  Enter Prefix to dial : ');
  781.       textcolor(11);
  782.       readln(prefix);
  783.       textcolor(cyan);
  784.       write('  Starting At (XXXX)   : ');
  785.       textcolor(11);
  786.       readln(Start_pos);
  787.       zz:=0;
  788.       textcolor(cyan);
  789.       write('  Ending At   (XXXX)   : ');
  790.       textcolor(11);
  791.       readln(End_pos);
  792.       textcolor(cyan);
  793.       write('  Timing Constant      : ');
  794.       textcolor(11);
  795.       readln(temp);
  796.       if length(temp)>0 then val(temp,timing_constant,i) else timing_constant:=14;
  797.       writeln;
  798.       textcolor(7);
  799.       write('  <');textcolor(white);write('Alt-H');textcolor(7);write('> For Help Menu');
  800.       val(start_pos,a,i);
  801.       val(end_pos,b,i);
  802.       dial_stop:=false;
  803.       gotoxy(48,3);
  804.       textcolor(11);
  805.       zz:=0;
  806.       write(' Status');
  807.       repeat
  808.             temp:='';
  809.             start_pos:='';
  810.             if a<9 then temp:='000';
  811.             if (a<99) and (a>9) then temp:='00';
  812.             if (a<999) and (a>99) then temp:='0';
  813.             str(a,start_pos);
  814.             t2:=temp+start_pos;
  815.             write_byte(chr(13));
  816.             delay(1000);
  817.             temp:=Dial_command+Prefix+t2+chr(13);
  818.             write_byte(temp);
  819.             gotoxy(48,5);
  820.             textcolor(cyan);
  821.             write('Dialing: ');textcolor(white);write(Prefix);
  822.             textcolor(12);write('-');textcolor(white);write(t2);
  823.             textcolor(cyan);
  824.             gotoxy(48,7);
  825.             write('Codes Found: ');
  826.             textcolor(white);
  827.             write(zz);
  828.             textcolor(cyan);
  829.             gotoxy(48,9);
  830.             if zz>0 then write('Last found:',code_found[zz],'    ') else write('Last found: None');
  831.             val(time,i,j);
  832.             j:=i+timing_constant;
  833.             repeat
  834.                   if carrier then
  835.                              begin
  836.                                   zz:=zz+1;
  837.                                   code_found[zz]:=prefix+'-'+t2;
  838.                                   if print_stat then write(lst,code_found[zz]:10);
  839.                                   hang_up;
  840.                                   j:=i-26;
  841.                                   Beep;
  842.                              end;
  843.                    val(time,i,k);
  844.                    if keypressed then
  845.                              begin
  846.                                   write_byte(chr(13));
  847.                                   read(kbd,ab);
  848.                                   if ab=chr(45) then
  849.                                               begin
  850.                                                     all_codes;
  851.                                                     menu;
  852.                                               end;
  853.                                   if ab=chr(50) then
  854.                                      begin
  855.                                           set_modem_parameters;
  856.                                           normvideo;
  857.                                           lowvideo;
  858.                                           window(1,1,80,25);
  859.                                           normvideo;
  860.                                           lowvideo;
  861.                                           window(6,9,73,19);
  862.                                       end;
  863.                                   if ab=chr(35) then
  864.                                      begin
  865.                                           help_wardial;
  866.                                           normvideo;
  867.                                           lowvideo;
  868.                                           window(1,1,80,25);
  869.                                           normvideo;
  870.                                           lowvideo;
  871.                                           window(6,9,73,19);
  872.                                      end;
  873.                                   if ab=chr(25) then toggle3_printer;
  874.                              end;
  875.             until i>j;
  876.       a:=a+1;
  877.       until dial_stop or (a>b);
  878.       beep;delay(1000);beep;delay(1000);beep;delay(1000);
  879.       write_byte(chr(13));
  880.       if zz>0 then all_codes;
  881.       menu;
  882. end;
  883.  
  884. Procedure Write_Status;
  885. var strg,strg2:sd;
  886. begin
  887. x2:=wherex;
  888. y2:=wherey;
  889. NormVideo;
  890. SelectWindow(4);
  891. gotoxy(1,1);
  892. if parity=none then strg:='None' else strg:='Even';
  893. textcolor(7);
  894. write(' Terminal Mode  ',speed:4,'-',strg:4,'-',Dbits:1,'-',Stop_bits:1,'                         <Alt-Y> for Help');
  895. NormVideo;
  896. Lowvideo;
  897. SelectWindow(5);
  898. gotoxy(x2,y2);
  899. end;
  900.  
  901. Procedure Quick_description;
  902. var bl:integer;
  903. begin
  904. xcoord:=wherex;
  905. ycoord:=wherey;
  906. move(screen1,screen2,4000);
  907. Normvideo;
  908. lowvideo;
  909. window(1,1,80,25);
  910. normvideo;
  911. textcolor(lightblue);
  912. frame(1,1,50,20);
  913. lowvideo;
  914. window(2,2,49,19);
  915. clrscr;
  916. gotoxy(1,1);
  917. textcolor(12);
  918. writeln('               Brief Desciptions');
  919. writeln;textcolor(7);
  920. writeln('  Service Number:  When prompted for this,');
  921. writeln('                   enter then number of a');
  922. writeln('                   service.');
  923. writeln('  Checksum number: Here you should enter');
  924. writeln('                   the number that another');
  925. writeln('                   computer can be reached.');
  926. writeln('                   Wardial needs to detect a');
  927. writeln('                   carrier.');
  928. writeln('  Code length:     This is the length of the');
  929. writeln('                   code being searched for.');
  930. writeln('  First digit:     The first digit of the');
  931. writeln('                   codes to be tested for.');
  932. Writeln('  Timing constant: This is the delay time');
  933. writeln('                   you wish to give to test');
  934. textcolor(15);
  935. write('  Press any key...');
  936. repeat until keypressed;
  937. read(kbd,ch);
  938. textcolor(7);
  939. writeln;
  940. writeln('                   for carrier. (ie. 12 is');
  941. writeln('                   good for sequential dialing');
  942. writeln;
  943. writeln('                   <Alt-H> gives a help menu in');
  944. writeln('                   the service code option and');
  945. writeln('                   the sequential dialer option.');
  946. writeln;
  947. writeln('                   Have fun. JRE.');
  948. for bl:=1 to 7 do writeln;
  949. gotoxy(1,17);
  950. textcolor(white+blink);
  951. writeln('              Hit any key...');
  952. repeat until keypressed;
  953. read(kbd,ch);
  954. normvideo;
  955. lowvideo;
  956. window(1,1,80,25);
  957. move(screen2,screen1,4000);
  958. gotoxy(xcoord,ycoord);
  959. end;
  960.  
  961.  
  962.  
  963. Procedure redial;
  964. var number,t,number_to_dial:sd;
  965.     i,j,k,l:integer;
  966.     leave:boolean;
  967. begin
  968. xcoord:=wherex;
  969. ycoord:=wherey;
  970. move(screen1,screen2,4000);
  971. Normvideo;
  972. lowvideo;
  973. window(1,1,80,25);
  974. normvideo;
  975. textcolor(3);
  976. frame(40,5,65,15);
  977. lowvideo;
  978. window(41,6,64,14);
  979. clrscr;
  980. gotoxy(1,1);
  981. textcolor(white);
  982. writeln('   Redial Number');
  983. textcolor(7);
  984. writeln;
  985. writeln(' Enter Number dial');
  986. write(' > ');
  987. readln(number);
  988. if length(number)>0 then
  989.         begin
  990.         textcolor(white+blink);
  991.         gotoxy(1,8);write(' ',chr(16));
  992.         textcolor(7);write('      Dialing      ');
  993.         textcolor(white+blink);write(chr(17));
  994.         leave:=false;
  995.         number_to_dial:=Dial_command+dial_type+number+chr(13);
  996.         repeat
  997.               if keypressed then leave:=true;
  998.               val(time,j,k);
  999.               i:=j+27;
  1000.               write_byte(Number_to_dial);
  1001.               repeat
  1002.                     if carrier then
  1003.                           begin
  1004.                                leave:=true;
  1005.                                i:=j-1;
  1006.                                beep;beep;beep;
  1007.                           end;
  1008.                     val(time,j,k);
  1009.                     if keypressed then leave:=true;
  1010.               until  (j>i) or leave;
  1011.         until leave;
  1012.         end;
  1013.         Normvideo;
  1014.         lowvideo;
  1015.         window(1,1,80,21);
  1016.         move(screen2,screen1,4000);
  1017.         set_up_recv_buffer;
  1018.         gotoxy(xcoord,ycoord);
  1019.         textcolor(maincolor);
  1020. end;
  1021.  
  1022. Procedure Terminal;
  1023. var leave, echo : boolean;
  1024.     a     : char;
  1025.     b     : smallstring;
  1026.     strg,prt:sd;
  1027.     tempbuf:string[81];
  1028.     bufpoint,i:integer;
  1029.  
  1030. begin
  1031.  Init_screen;
  1032.  Clrscr;
  1033.  textcolor(12);
  1034.  frame(wtab[4,1]-1,wtab[4,2]-1,wtab[4,3]+1,wtab[4,4]);
  1035.  lowvideo;
  1036.  selectWindow(4);
  1037.  gotoxy(1,1);
  1038.  maincolor:=11;
  1039.  if parity=none then strg:='None' else strg:='Even';
  1040.  textcolor(7);
  1041.  if printer then prt:='ON'else Prt:='OFF';
  1042.  write(' Terminal Mode  ',speed:4,'-',strg:4,'-',Dbits:1,'-',Stop_bits:1,'                        <Alt-Y> for Help');
  1043.  normvideo;
  1044.  lowvideo;
  1045.  textcolor(lightcyan);
  1046.  selectWindow(5);
  1047.  gotoxy(1,1);
  1048.  bufpoint:=1;
  1049.  init_port;
  1050.  tempbuf:='';
  1051.  writeln('Terminal ready. <Alt-Y> for Menu. <Alt-P> for Parameters.');
  1052.  beep;
  1053.  echo:=false;
  1054.  set_up_recv_buffer;
  1055.  leave := false;
  1056.  while not leave do
  1057.  begin
  1058.   if keypressed then
  1059.   begin
  1060.    repeat read(kbd,a) until a <> chr(27);
  1061.       i:=ord(a);
  1062.       case i of
  1063.           30:begin
  1064.                        Set_modem_parameters;
  1065.                        Selectwindow(5);
  1066.                   end;
  1067.           17:redial;
  1068.           19:rcv_asc;
  1069.           31:Send_asc;
  1070.           24:hang_up;
  1071.           21:help;
  1072.           16:Menu;
  1073.           27:break;
  1074.           25:begin
  1075.                        Set_parameters;
  1076.                        Write_status;
  1077.                        Textcolor(11);
  1078.                   end;
  1079.           end;
  1080.    if (a = chr(18)) and echo then
  1081.           begin
  1082.               echo:=false;
  1083.               beep;
  1084.           end
  1085.    else
  1086.    if (a = chr(18)) and not echo then
  1087.          begin
  1088.               writeln;Writeln('Echo On.');
  1089.               echo:=true;
  1090.               beep;
  1091.          end
  1092.   else
  1093.   if (a<chr(15)) or (a>chr(31)) then
  1094.        begin
  1095.           if echo then write(a);
  1096.           write_byte(a);
  1097.        end;
  1098.   end;
  1099.   if commpressed then write(cinkey);
  1100.  end;
  1101. end;
  1102.  
  1103.  
  1104. Procedure Menu;
  1105. var i:integer;
  1106.     cr:char;
  1107. begin
  1108. normvideo;
  1109. lowvideo;
  1110. window(1,1,80,25);
  1111. normvideo;
  1112. textcolor(12);
  1113. frame(9,4,70,17);
  1114. lowvideo;
  1115. remove_port;
  1116. window(10,5,69,16);
  1117. clrscr;
  1118. gotoxy(1,1);
  1119. textcolor(15);
  1120. Writeln('                       Wardial 1.2');
  1121. textcolor(7);
  1122. writeln('                            by   ');
  1123. Writeln('                       Jim Everingham ');
  1124. textcolor(15);
  1125. writeln('                           1984 ');
  1126. writeln;
  1127. textcolor(7);write('                <');textcolor(15);write('1');textcolor(7);writeln('> Service Code Finder');
  1128. textcolor(7);write('                <');textcolor(15);write('2');textcolor(7);writeln('> Sequential Dialer');
  1129. textcolor(7);write('                <');textcolor(15);write('3');textcolor(7);writeln('> Terminal Mode');
  1130. textcolor(7);write('                <');textcolor(15);write('4');textcolor(7);writeln('> Modem Parameters');
  1131. textcolor(7);write('                <');textcolor(15);write('5');textcolor(7);writeln('> Quick descriptions');
  1132. textcolor(7);write('                <');textcolor(15);write('6');textcolor(7);writeln('> Exit to System');
  1133. beep;
  1134. print_stat:=false;
  1135. Term_ready(false);
  1136. term_ready(true);
  1137. repeat
  1138. repeat
  1139. read(kbd,ch)
  1140. Until ch in ['1','2','3','4','5','6'];
  1141.       case ch of
  1142.           '1': wardial;
  1143.           '2': Sequential_dial;
  1144.           '3': begin
  1145.                   terminal;
  1146.                   set_up_recv_buffer;
  1147.              end;
  1148.           '4': Set_modem_parameters;
  1149.           '5': Quick_description;
  1150.           '6': begin
  1151.                   init_screen;
  1152.                   gotoxy(1,1);
  1153.                   write('Terminated');
  1154.                   gotoxy(1,25);
  1155.                   halt;
  1156.              end;
  1157.           end;
  1158. until cr='6';
  1159. normvideo;
  1160. ClrScr;
  1161. Window(1,1,80,25);
  1162. ClrScr;
  1163. end;
  1164.  
  1165. Procedure Opening_Screen;
  1166. begin
  1167. crtinit;
  1168. textcolor(white);
  1169. frame(4,4,76,21);
  1170. Lowvideo;
  1171. window(5,5,75,20);
  1172. textcolor(7);
  1173. ClrScr;
  1174. gotoxy(1,2);
  1175. writeln;Writeln('                             WARDIAL 1.2');
  1176. Writeln;
  1177. Writeln('       The Author of this Program takes no responsibility for the');
  1178. Writeln('       results of it''s uses.   It was  Developed for  experimental');
  1179. writeln('       purposes and to illistrate certain techniques.');
  1180. writeln('       Version 1.2 is a little more debugged and has a few extra');
  1181. writeln('       features. Hope you enjoy it.');
  1182. writeln('       Any inquiries can be sent to:');
  1183. writeln('                          Jim Everingham');
  1184. writeln('                          215 West Fairmount Ave.');
  1185. writeln('                          Apt #306 Fairmount Hills');
  1186. writeln('                          State College PA, 16801');
  1187. beep;
  1188. crtexit;
  1189. repeat until keypressed;
  1190. Normvideo;
  1191. crtexit;
  1192. lowvideo;
  1193. window(1,1,80,25);
  1194. normvideo;
  1195. clrscr;
  1196. end;
  1197.  
  1198.  
  1199. Procedure Wardial;
  1200. var test : boolean;
  1201.     a     : char;
  1202.     b     : smallstring;
  1203.     temp: sd;
  1204.     timing_constant,result: integer;
  1205.  
  1206. begin
  1207. lowvideo;
  1208. window(1,1,80,25);
  1209. clrscr;
  1210. textcolor(11);
  1211. writeln('Time is: ',time2);
  1212. writeln('Enter time to stop in format above ');
  1213. write('<Return> for none: ');
  1214. readln(Stop_time);
  1215. if length(stop_time)=7 then stop_time:='0'+stop_time;
  1216. normvideo;
  1217. clrscr;
  1218. beep;
  1219. gotoxy(7,12);textcolor(11);writeln('Trying Code:');
  1220. gotoxy(47,12);textcolor(11);writeln('Codes Found:');
  1221. textcolor(lightblue);
  1222. for ii:=1 to 3 do
  1223.        frame(wtab[ii,1]-1,wtab[ii,2]-1,wtab[ii,3]+1,wtab[ii,4]+1);
  1224. Lowvideo;
  1225. selectwindow(1);
  1226. gotoxy(1,1);
  1227. insline;
  1228. textcolor(15);
  1229. writeln('                       ',chr(205),chr(205),chr(16),'   Wardial 1.2   ',chr(17),chr(205),chr(205));
  1230. textcolor(3);writeln;
  1231. Write('   Enter Service Number: ');
  1232. textcolor(11);
  1233. readln(num);
  1234. textcolor(3);
  1235. service_number:=Dial_command+Dial_type+num+Pause_command;
  1236. write('   Enter Checksum Number: ');
  1237. textcolor(11);
  1238. readln(checksum_number);
  1239. textcolor(3);
  1240. write('   Enter timing Constant: ');
  1241. textcolor(11);
  1242. readln(temp);
  1243. val(temp,timing_constant,result);
  1244. if timing_constant <=5 then timing_constant:=27;
  1245. textcolor(3);
  1246. write('   Enter Code Length: ');
  1247. textcolor(11);
  1248. readln(temp);
  1249. val(temp,code_length,result);
  1250. textcolor(3);
  1251. write('   First number of code (1 digit): ');
  1252. textcolor(11);
  1253. readln(start_num);
  1254. if code_length<5 then code_length:=5;
  1255. textcolor(7);write('   <');
  1256. textcolor(15);write('Alt-H');
  1257. textcolor(7);write('> For Help menu');
  1258. if length(stop_time)=8 then begin
  1259.                textcolor(cyan);
  1260.                gotoxy(45,3);
  1261.                writeln('Program timed to stop ');
  1262.                gotoxy(45,4);
  1263.                write('at: ');
  1264.                textcolor(lightred+blink);
  1265.                write(stop_time);
  1266.                end;
  1267. normvideo;
  1268.  leave := false;
  1269.  zz:=0;
  1270.  while not leave do
  1271.  begin
  1272.   if keypressed then
  1273.   begin
  1274.   leave:=true;
  1275.   end
  1276.   else
  1277.   begin
  1278.        test:=false;
  1279.        get_code(code);
  1280.        if (length(stop_time)=8) and (time2 > stop_time) then
  1281.                          begin
  1282.                               leave:=true;
  1283.                               beep;delay(1000);beep;delay(1000);delay(1000);
  1284.                               if zz>0 then all_codes;
  1285.                               set_up_recv_buffer;
  1286.                               menu;
  1287.                           end;
  1288.        Send_code(Service_number,code,checksum_number);
  1289.        test_carrier(test,code,timing_constant);
  1290.        if test then
  1291.           begin
  1292.           remove_port;
  1293.           Menu;
  1294.           end;
  1295.        write_codes;
  1296.   end;
  1297.  end;
  1298.   if zz>0 then all_codes;
  1299.   beep;delay(1000);beep;delay(1000);beep;delay(1000);
  1300.   set_up_recv_buffer;
  1301.   menu;
  1302. end;
  1303.  
  1304. Procedure Make_data_file;
  1305. var a:string[20];
  1306.     infile:text;
  1307.     file_name:string[20];
  1308. begin
  1309. file_name:='WARDIAL.DTA';
  1310. assign(infile,file_name);
  1311. rewrite(infile);
  1312. textcolor(lightgreen);
  1313. read(kbd,ch);
  1314. writeln;Writeln('Creating  WARDIAL.DTA.');
  1315. write('Enter Baud      : ');
  1316. readln(a);
  1317. if (a='1200') or (a='300') or (a='9600') then writeln(infile,a)
  1318. else writeln(infile,'1200');
  1319. write('Enter Stop bits : ');
  1320. readln(a);
  1321. if (a<>'1') or (a<>'2') then writeln(infile,'1')
  1322. else writeln(infile,a);
  1323. write('Parity (E/N)    : ');
  1324. readln(a);
  1325. if upcase(copy(a,1,1))='E' then writeln(infile,'E') else writeln(infile,'N');
  1326. write('Enter Data Bits : ');
  1327. readln(a);
  1328. if (a='7') or (a='8') then writeln(infile,a) else writeln(infile,'8');
  1329. writeln;write('Are you Using a Hayes Or compatible Modem ? ');
  1330. readln(a);
  1331. if (copy(a,1,1)='Y') or (copy(a,1,1)='y') then begin
  1332.                            writeln;
  1333.                            writeln('Hayes Mode selected.');
  1334.                            writeln(infile,'ATD');
  1335.                            dial_type:='ATD';
  1336.                            writeln(infile,',,,,');
  1337.                            pause_command:=',,,,';
  1338.                            end
  1339. else
  1340.     begin
  1341.          writeln;
  1342.          writeln('Non-Hayes Mode Selected.');
  1343.          write('Enter Dial Command (ie. ATDT): ');
  1344.          readln(dial_command);
  1345.          writeln(infile,dial_command);
  1346.          write('Enter Pause Command          : ');
  1347.          readln(Pause_command);
  1348.          writeln(infile,pause_command);
  1349.          Dial_type:='';
  1350.     end;
  1351. delay(2000);
  1352. close(infile);
  1353. end;
  1354.  
  1355.  
  1356.  
  1357. Procedure Initial_Setup;
  1358. var a:string[40];
  1359.     ok: boolean;
  1360.     infile:text;
  1361.     file_name:string[20];
  1362.     result:integer;
  1363. begin
  1364. ok:=false;
  1365. ClrScr;
  1366. textcolor(11);
  1367. Writeln('Reading in data...');
  1368. file_name:='WARDIAL.DTA';
  1369. assign(infile,file_name);
  1370. {$I-} reset(infile) {$I+};
  1371. ok:=(ioresult=0);
  1372. if not ok then make_Data_file
  1373. else
  1374. begin
  1375.   readln(infile,a);
  1376.   val(a,speed,result);
  1377.   readln(infile,a);
  1378.   val(a,stop_bits,result);
  1379.   readln(infile,a);
  1380.   if a='E' then parity:=even else parity:=none;
  1381.   readln(infile,a);
  1382.   val(a,dbits,result);
  1383.   readln(infile,dial_command);
  1384.   readln(infile,pause_command);
  1385.   close(infile);
  1386. end;
  1387. ClrScr;
  1388. term_ready(true);
  1389. end;
  1390.  
  1391.  
  1392. var a     : char;
  1393.     b     : smallstring;
  1394.  
  1395. (* This is the Main Program *)
  1396.  
  1397. begin
  1398.      Dial_speed:='70';
  1399.      clrscr;
  1400.      maincolor:=11;
  1401.      xon:=chr(31);
  1402.      xoff:=chr(16);
  1403.      Print_stat:=false;
  1404.      Dial_type:='T';
  1405.      Speaker:='M1';
  1406.      Duplex:='F1';
  1407.      Command_echo:='E1';
  1408.      textcolor(lightcyan);
  1409.      Response_time:='6';
  1410.      Setup;
  1411.      Remove_port;
  1412.      Opening_screen;
  1413.      initial_setup;
  1414.      repeat
  1415.      menu;
  1416.      until keypressed;
  1417. end.
  1418.